Skip to content

Conversation

Ahmedhossamdev
Copy link
Member

@Ahmedhossamdev Ahmedhossamdev commented Sep 17, 2025

Fix: #87

@Ahmedhossamdev Ahmedhossamdev changed the title Feat/missing fields arrival departure stop 87 feat: real-time predictions and distance calculations Sep 17, 2025
@Ahmedhossamdev Ahmedhossamdev marked this pull request as ready for review September 22, 2025 20:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements real-time predictions and distance calculations for transit systems by integrating GTFS realtime data with scheduled transit information. The changes add support for predicting arrival/departure times based on real-time trip updates and calculating distances between vehicles and stops.

Key changes:

  • Added real-time trip and vehicle lookup functionality with hash maps for improved performance
  • Implemented predicted arrival/departure time calculations using GTFS realtime trip updates
  • Added distance calculation methods for determining remaining distance to stops and number of stops away
  • Refactored next stop finding logic to use vehicle's current stop sequence instead of position-based calculations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/restapi/vehicles_helper.go Added helper functions for vehicle data extraction and removed redundant timestamp calculations
internal/restapi/trips_helper.go Updated trip building logic to use active trip ID and simplified next stop finding
internal/restapi/arrival_and_departure_for_stop_handler.go Implemented real-time predictions and distance calculations for arrival/departure responses
internal/models/trip_details.go Reorganized TripStatusForTripDetails struct fields alphabetically
internal/gtfs/realtime.go Added lookup map rebuild functions for efficient real-time data access
internal/gtfs/gtfs_manager_mock.go Updated mock to maintain vehicle lookup consistency
internal/gtfs/gtfs_manager.go Added lookup maps and helper methods for real-time data access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if numberOfStopsAwayPtr != nil {
numberOfStopsAway = *numberOfStopsAwayPtr
} else {
numberOfStopsAway = -1
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -1 as a magic number to indicate unknown stops away is unclear. Consider defining a constant like const UnknownStopsAway = -1 or using a pointer type to distinguish between 0 stops away and unknown.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing fields in arrival-and-departure-for-stop endpoint implementation
1 participant